import Constants from "./libs/Constants";
import GameData from "./libs/GameData";
import Helper from "./libs/HelperMgr";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Index extends cc.Component {

  @property(cc.Label)
  goldnum: cc.Label = null;



  start(){
      if(!GameData.instance.isSignedToday){
        Helper.showUI(Constants.UIName.UISign)
      }
  }

  update() {
    if(this.goldnum){
      this.goldnum.string = GameData.instance.playGold.toString();
    }
      
  }

  onBeignNormal(){
    GameData.instance.gameModel = true;
    GameData.instance.gameStage = 1;
    cc.director.loadScene("game");
  }

  onBeignContinue(){
    GameData.instance.gameModel = true;
    if(!GameData.instance.gameBack){
      GameData.instance.gameStage = GameData.instance.gameMaxStage;
    }
    cc.director.loadScene("game");
  }

  onBeignCrazy(){
    GameData.instance.gameModel = false;
    cc.director.loadScene("game");
  }



  onRank(){
    Helper.showUI(Constants.UIName.UIRank)
  }

  onShop(){
    Helper.showUI(Constants.UIName.UIShop)
  }

  onSign(){
    Helper.showUI(Constants.UIName.UISign)
  }

  onLevel(){
    Helper.showUI(Constants.UIName.UILevel)
  }
}
